package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.AutoDto;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.dtos.WmNewsPageReqDto;
import com.heima.wemedia.service.WmNewsServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/news")
public class WmNewsController {
@Autowired
    WmNewsServer wmNewsServer;
//查询自媒体文章
    @PostMapping("/list")
    public ResponseResult findAll(@RequestBody WmNewsPageReqDto dto){
        ResponseResult responseResult= wmNewsServer.findList(dto);

        return  responseResult;
    }
    //发布文章
    @PostMapping("/submit")
    public ResponseResult submitNews(@RequestBody WmNewsDto dto) throws Exception {
        return wmNewsServer.submitNews(dto);
    }
    //上下架
    @PostMapping("/down_or_up")
    public ResponseResult downUp(@RequestBody WmNewsDto dto){
      return  wmNewsServer.downUp(dto);
    }

    //admin查询文章列表
    @PostMapping("/list_vo")
    public ResponseResult list_vo(@RequestBody  AutoDto dto){
      return   wmNewsServer.list_vo(dto);
    }
    //文章详情
    @GetMapping("/one_vo/{id}")
    public ResponseResult one_voId(@PathVariable Integer id){
        return   wmNewsServer.one_voId(id);
    }
    //审核失败
    @PostMapping("/auth_fail")
    public ResponseResult auth_fail(@RequestBody AutoDto dto){
        return wmNewsServer.auth_fail(dto);
    }
    //审核成功
    @PostMapping("/auth_pass")
    public ResponseResult auth_pass(@RequestBody AutoDto dto){
        return wmNewsServer.auth_pass(dto);
    }

}